package com.xcity.game.equip.suit4.impl;

import com.xcity.game.combat.Action;
import com.xcity.game.combat.ActionEffect;
import com.xcity.game.combat.Combat;
import com.xcity.game.combat.CombatUtils;
import com.xcity.game.combat.unit.CombatUnit;
import com.xcity.game.common.GameStaticConfig;
import com.xcity.game.equip.suit4.BaseSuit4;
import com.xcity.game.equip.template.EquipSuitEffectTemplate;

/**
 * 范思哲4件套<br/>
 * 受到伤害时{20}%的几率使用普通攻击反击对方<br/>
 * @author yang.li
 *
 */
public class Suit4Versace extends BaseSuit4 {

	public Suit4Versace(CombatUnit unit, EquipSuitEffectTemplate template) {
		super(unit, template);
	}

	@Override
	public void afterDamage(ActionEffect effect) {
		if (unit.getId() != effect.getUnitId()) {
			return;
		}
		if (!effect.getUnit().isDied() && effect.getHpDelta() < 0 && Combat.RND.nextInt(GameStaticConfig.percentBase) < template.getSuit4Param(0)) {
			Action newAct = new Action(effect.getUnit());
			effect.ref().ref().add(newAct);
			ActionEffect eff = newAct.addTarget(effect.ref().unit);
			CombatUtils.calcAttack(eff);
		}
	}


}
